//
//  PKDetailTableViewCell.m
//  PianKe
//
//  Created by lanou on 15/12/23.
//  Copyright © 2015年 KFC. All rights reserved.
//

#import "PKDetailTableViewCell.h"



@implementation PKDetailTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addSubViews];
        
    }
    
    
    return self;
    
}


- (void)addSubViews
{
    
    self.coverImageV = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 40, 40)];
  //  self.coverImageV.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:self.coverImageV];
    
    self.titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.coverImageV.right + 10, self.coverImageV.top, 200, self.coverImageV.height / 2)];
  //  self.titlelabel.backgroundColor = [UIColor yellowColor];
    self.titlelabel.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.titlelabel];
    
    UIImageView *countImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.titlelabel.left, self.titlelabel.bottom + 10, 10, 10)];
    countImageV.image = [UIImage imageNamed:@"shengyin"];
    [self.contentView addSubview:countImageV];
    
    self.musicVisitLabel = [[UILabel alloc] initWithFrame:CGRectMake(countImageV.right, countImageV.top, self.titlelabel.width / 3, 10)];
   // self.musicVisitLabel.backgroundColor = [UIColor greenColor];
    self.musicVisitLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.musicVisitLabel];
    
    UIButton *actionButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    actionButton.frame = CGRectMake(kScreenWidth - 50, self.coverImageV.height / 2, 30, 30);
    [actionButton setBackgroundImage:[UIImage imageNamed:@"bofang"] forState:(UIControlStateNormal)];
    [self.contentView addSubview:actionButton];
    
    self.myNewImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20,20)];
    [self.coverImageV addSubview:self.myNewImageV];
    
    
}



//
-(void)setModel:(PKDetailModel *)model
{
    _model = model;
    
    // 赋值:
    [self.coverImageV sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:nil];
    self.titlelabel.text = model.title;
    self.musicVisitLabel.text = model.musicVisit;
    
    
    // 判断是否为新专辑
    if (model.isnew) {
        
    
        self.myNewImageV.image = [UIImage imageNamed:@"new2"];
        
    } else
    {
        self.myNewImageV.image = nil;
       
    }
    

    
    
}











- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
